/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;


import POJO.Thamso;
import UTIL.HibernateUtil;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 *
 * @author nhlvu07db373
 */
public class ThamsoDAO extends HibernateDaoSupport{
    private Session session;
   /**
     * lấy số lượng sản phẩm trên trang
     * @return 
     */
    public Thamso laySoLuongSanPhamTrenTrang() {
        Thamso thamso=null;
        session = HibernateUtil.getSessionFactory().openSession();
        try {
            org.hibernate.Transaction ts = session.beginTransaction();
           Criteria criteria = session.createCriteria(Thamso.class); 
            List list = criteria.list();
            thamso = (Thamso) list.get(0);
            ts.commit();
            session.flush();
        } catch (Exception ex) {
            if (session.getTransaction().isActive()) {
                session.getTransaction().rollback();
            }
            System.err.println(ex.getMessage().toString());
        } finally {
            session.close();
        }        
        return thamso;
    }   
}
